<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>ECharts</title>
    <!-- 引入 echarts.js -->
    <script src="https://cdn.jsdelivr.net/npm/echarts@4.9.0/dist/echarts.min.js"></script>
  </head>
  <body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 600px; height: 400px"></div>
    <script>
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("main"));

      // 指定图表的配置项和数据
      var option = {
        series: [
          {
            type: "sankey",
            data: [
              { name: "数据1" },
              { name: "数据2" },
              { name: "数据3" },
              { name: "数据4" },
            ],
            links: [
              { source: "数据1", target: "数据2", value: 2 },
              { source: "数据1", target: "数据3", value: 2 },
              { source: "数据2", target: "数据4", value: 2 },
              { source: "数据3", target: "数据4", value: 2 },
            ],
          },
        ],
      };

      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
    </script>
  </body>
</html>
